#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;
/*
void TelephoneNum(set<string>& s, vector<string>& vs){
    for(size_t i = 0; i < vs.size(); ++i){
        string num;
        string PhoneNum = "22233344455566677778889999";
        size_t cnt = 0;
        for(size_t j = 0; j < vs[i].size(); ++j){
            
            if(vs[i][j] == '-') continue;

            if(vs[i][j] >= 'A' && vs[i][j] <= 'Z'){
                num.push_back(PhoneNum[vs[i][j] - 'A']);
                ++cnt;
            }
            else if(vs[i][j] >= '0' && vs[i][j] <= '9'){
                num.push_back(vs[i][j]);
                ++cnt;
            }
            if(cnt == 3) num.push_back('-');
        }
        s.insert(num);
    }
}*/

int main()
{
    int n;
    while(cin >> n){
        set<string> number;
        string s;
        for(size_t i = 0; i < n; ++i){
            cin >> s;
            string num;
            string PhoneNum = "22233344455566677778889999";
            size_t cnt = 0;
            for(size_t j = 0; j < s.size(); ++j){
                if(s[j] == '-') continue;
                if(s[j] >= 'A' && s[j] <= 'Z'){
                    num.push_back(PhoneNum[s[j] - 'A']);
                    ++cnt;
                }
                else if(s[j] >= '0' && s[j] <= '9'){
                    num.push_back(s[j]);
                    ++cnt;
                }
                if(cnt == 3) num.push_back('-');
               
            }
            number.insert(num);
        }
        for (set<string>::iterator it = number.begin(); it != number.end(); ++it)
            cout << *it << endl;
        cout << endl;
    }
    return 0;
}